<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        /* let obj = {
            name: "张三",
            age: 18,
            gender: "男",
            skill: ["吃", "喝", "玩", "乐"]
        }
        // let { name: a, age: b, gender: c, skill: d } = obj
        // console.log(a,b,c,d);
        //简写形式
        let { name, age, gender, skill } = obj
        console.log(name, age, gender, skill); */

        let obj = {
            name: "张三",
            age: 18,
            gender: "男",
            skill: ["吃", "喝", "玩", "乐"],
            hobbies: "男"
        }
        //不完全解构
        // let { name: a, age: b, gender: c } = obj
        // console.log(a,b,c);

        //解构失败
        // let {name:a,age:b,gender:c,skill:d,hobbies:e} = obj
        // console.log(a,b,c,d,e)

        //设置解构默认值
        let { name: a, age: b, gender: c, skill: d, hobbies: e = "女" } = obj;
        console.log(a, b, c, d, e);
    </script>
</body>

</html>